package com.aptemo.webetek.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

import com.aptemo.webetek.client.commands.Response;
import com.aptemo.webetek.client.enums.EnumBetStatus;
import com.aptemo.webetek.client.enums.EnumBetType;

public class BetBean implements Response, Comparable<BetBean>, Serializable
{
	/**
	 * 
	 */
	private static final long	serialVersionUID	= -1776591904342978351L;

	private String				id;

	private ArrayList<PickBean>	picks				= new ArrayList<PickBean>();

	private Double				amount;

	private EnumBetStatus		status;

	private EnumBetType			betType;

	private Date				date;

	private Double				earnings			= 0.0;

	private double				totalOdds			= 0.0;

	protected BetBean()
	{
	}

	public BetBean(double amount, Date date)
	{
		// setUser(user);
		setAmount(amount);
		setDate(date);

	}

	public void setAmount(double amount)
	{
		this.amount = amount;
	}

	public double getAmount()
	{
		return amount;
	}

	public void setStatus(EnumBetStatus status)
	{
		this.status = status;
	}

	public EnumBetStatus getStatus()
	{
		return status;
	}

	public void setDate(Date date)
	{
		this.date = date;
	}

	public Date getDate()
	{
		return date;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getId()
	{
		return id;
	}

	public EnumBetType getBetType()
	{
		return betType;
	}

	public void addPick(PickBean pick)
	{
		picks.add(pick);
	}

	public void setPicks(ArrayList<PickBean> picks)
	{
		this.picks = picks;
	}

	public ArrayList<PickBean> getPicks()
	{
		return picks;
	}

	public void setEarnings(Double winnings)
	{
		this.earnings = winnings;
	}

	public double getEarnings()
	{
		if (earnings == null)
			return 0.0;
		return earnings;
	}

	public void setBetType(EnumBetType betType)
	{
		this.betType = betType;
	}

	public double getOddsSum()
	{
		double sum = 0.0;

		for (PickBean pick : picks)
		{
			sum += pick.getOdds();
		}
		return sum;
	}

	@Override
	public int compareTo(BetBean o)
	{
		return this.getDate().compareTo(o.getDate());
	}

	public void setTotalOdds(Double totalOdds)
	{
		// TODO Auto-generated method stub

	}

	public double getTotalOdds()
	{
		return totalOdds;
	}
}
